/**
 * Created by Administrator on 2017/9/13.
 */
var React = require('react');


var Bheader = require('../widget/Bheader');
var Footer = require('../widget/Footer');
var ajax = require('../tools/ajax');
var Icon = require('../components/Icon');

module.exports = React.createClass({
    getInitialState: function () {
        return {
            theme:"Default",//Default/Blue
            Id:"",
            flag:false,
            userInfo:[],
            jifen:0
        }
    },
    myScroll:"",

    componentDidMount: function () {
        this.getUserInfoByUid();
        setTimeout(this.iscroll,500);
    },
    /**iScroll插件*/
    iscroll(){
        var p =this;
        p.myScroll = new IScroll("#vipWrapper",{
            // 默认iscroll会拦截元素的默认事件处理函数，我们需要响应onClick，因此要配置
            preventDefault: false,
            // 禁止缩放
            zoom: false,
            // 支持鼠标事件，因为我开发是PC鼠标模拟的
            mouseWheel: true,
            // 滚动事件的探测灵敏度，1-3，越高越灵敏，兼容性越好，性能越差
            probeType: 3,
            // 拖拽超过上下界后出现弹射动画效果，用于实现下拉/上拉刷新
            bounce: true,
            // 展示滚动条
            scrollbars: false
        });
    },
    bottom(e){
        var Id = e.currentTarget.getAttribute("data");
        switch(Id){
            case "1": this.setState({Id:"1"});break;
            case "2": this.setState({Id:"2"});break;
            case "3": this.setState({Id:"3"});break;
        }
        if(this.state.flag){
            this.setState({flag:false})
        }else{
            this.setState({flag:true})
        }
    },
    /**获取积分*/
    getUserInfoByUid(){
        var p =this;
        var userId = localStorage.getItem("userId");
        ajax("POST","getUserInfoByUid",{userId:userId},function(dt){
            if(dt&&dt.success){
                var obj =dt.data[0];
                p.setState({jifen:obj.jifen});
                console.log(obj.jifen);
            }
        })
    },
//<p className="fr"><span className="ff00">20</span>积分 <Icon icon="#icon-fanhui"  className="tiaoZhuan"/></p>
    render: function () {
        var p = this;
        return (
            <div className="main"  id="main">
                <Bheader theme={this.state.theme} title="积分规则" headr="false" hact="#integralMall"></Bheader>
                <div id="vipWrapper" className="container-t noFooter vip">
                    <div style={{minHeight:"31.18rem"}}>
                        <div className="jiFenRule">
                            <Icon icon="#icon-caiwufeiyongqianjinbihuobi" className="jiFen"/>
                            <p>我的积分：<span className="jiFen-numo">{p.state.jifen}</span></p>
                        </div>
                        <p className="blankSet"></p>
                        <p className="jiFenText">
                            积分是您在跨乐购手机客户端进行注册、购物、晒单、等操作时获得的通用积分， 拥有积分后可以使用积分抵订单金额购买商品哦~
                        </p>
                        <p className="blankSet1"></p>
                        <div className="jifenExchangeText"><span>如何获得积分?</span></div>
                        <div className="reg">
                            <span className="fl">用户注册</span>
                        </div>
                        <div className="reg">
                            <span className="fl">点评奖励</span>
                        </div>
                        <div className="reg">
                            <span className="fl">购物返积分</span>
                        </div>
                     </div>
                </div>
            </div>
        )
    }
});

